﻿//弹出提示
function ShowMsg(msg) {
    layui.use('layer', function () {
        layer = layui.layer;
        if (msg != undefined && msg != '' && msg != null) {
            layer.msg(msg, { offset: '30px', anim: 6 });
        }
    });
}
//全选、反选
function ischeck(obj) {
    var $obj = $(obj);
    var ArrayUrl = $("#ArrayAct").val();
    var istrue = $obj.is(":checked");
    if (istrue) {
        $(".layui-table").find("input[type='checkbox']").prop("checked", true);
        $obj.prop("checked", true);
        var val = "";
        $(".layui-table tr:gt(0)").each(function () {
            val += $(this).find("input[type='checkbox']:checked").val() + ",";
        })
        val = val.substr(0, val.length - 1);
        $("#alldel").attr("href", ArrayUrl + "?array=" + val);
    }
    else {
        $(".layui-table").find("input[type='checkbox']").prop('checked', false);
        $obj.prop('checked', false);
        $("#alldel").attr("href", "javascript:void(0)");
    }
}
//多选
function ischeckEx(obj) {
    var $obj = $(obj);
    var ArrayUrl = $("#ArrayAct").val();
    var istrue = $obj.is(":checked");
    if (istrue) {
        $obj.prop("checked", true);
    }
    else {
        $obj.removeAttr("checked");
    }
    var len = $(".layui-table").find("input[type='checkbox']:checked").length;
    if (len == 0) {
        $("#cbname").removeAttr("checked");
        $("#alldel").attr("href", "javascript:void(0)");
    }
    else if (len > 0) {
        if (len == 1) {
            $("#cbname").prop("checked", true);
        }
        var val = "";
        $(".layui-table tr:gt(0)").each(function () {
            if ($(this).find("input[type='checkbox']:checked").val() != undefined) {
                val += $(this).find("input[type='checkbox']:checked").val() + ",";
            }
        })
        val = val.substr(0, val.length - 1);
        $("#alldel").attr("href", ArrayUrl + "?array=" + val);
    }
}
//扩展多个按钮
function ischeckAct(obj) {
    var $obj = $(obj);
    var ArrayUrl = $("#ArrayAct").val();
    var istrue = $obj.is(":checked");
    if (istrue) {
        $(".layui-table").find("input[type='checkbox']").prop("checked", true);
        $obj.prop("checked", true);
        var val = "";
        $(".layui-table tr:gt(0)").each(function () {
            val += $(this).find("input[type='checkbox']:checked").val() + ",";
        })
        val = val.substr(0, val.length - 1);
        $("#allArrayID").attr("value", ArrayUrl + "?array=" + val);
    }
    else {
        $(".layui-table").find("input[type='checkbox']").prop('checked', false);
        $obj.prop('checked', false);
        $("#allArrayID").attr("value", "");
    }
}
//扩展多选
function ischeckActEx(obj) {
    var $obj = $(obj);
    var ArrayUrl = $("#ArrayAct").val();
    var istrue = $obj.is(":checked");
    if (istrue) {
        $obj.prop("checked", true);
    }
    else {
        $obj.removeAttr("checked");
    }
    var len = $(".layui-table").find("input[type='checkbox']:checked").length;
    if (len == 0) {
        $("#cbname").removeAttr("checked");
        $("#allArrayID").attr("value", "");
    }
    else if (len > 0) {
        if (len == 1) {
            $("#cbname").prop("checked", true);
        }
        var val = "";
        $(".layui-table tr:gt(0)").each(function () {
            if ($(this).find("input[type='checkbox']:checked").val() != undefined) {
                val += $(this).find("input[type='checkbox']:checked").val() + ",";
            }
        })
        val = val.substr(0, val.length - 1);
        $("#allArrayID").attr("value", ArrayUrl + "?array=" + val);
    }
}

function GoArrayAct(key) {
    var allArrayIDUrl = $("#allArrayID").val();
    if (allArrayIDUrl != undefined && allArrayIDUrl != '' && allArrayIDUrl != null) {
        window.location.href = allArrayIDUrl + "&Key=" + key;
    }
}
